package com.jari.lg.service.profile.device;

import com.jari.lg.domain.DevBase;
import com.jari.lg.domain.DeverrReasonHisEntity;
import com.jari.lg.mapper.DevErrReasonHisMapper;
import com.jari.lg.mapper.DeverrIntervalHisEntityMapper;
import com.jari.lg.mapper.DeverrReasonHisEntityMapper;
import com.jari.lg.utils.BaseData;
import com.jari.lg.utils.UUIDUtils;
import com.jari.lg.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DeverrReasonHisService {

    @Autowired
    private DeverrReasonHisEntityMapper deverrReasonHisEntityMapper;



    /*
    *
    * */
    public void makeInfo(){
        DeverrReasonHisEntity entity;
        List<DevBase> devBases = BaseData.devBaseList;
        String weather = Utils.makeWeather();
        String windDirection = Utils.makeWindDirection();
        String windLevel = Utils.windLevel();
        for(DevBase devBase : devBases){
            entity = generate(devBase, weather, windDirection, windLevel);
            deverrReasonHisEntityMapper.insert(entity);
        }
    }

    private DeverrReasonHisEntity generate(DevBase devBase, String weather, String windDirection, String windLevel){
        DeverrReasonHisEntity entity = new DeverrReasonHisEntity();
        entity.setCityid("021");
        entity.setDistrictid("310115");
        entity.setCityname("上海市");
        entity.setDistrictname("浦东新区");
        entity.setDatetime(new Date());
        entity.setDevicetype(devBase.getDevicetype());
        entity.setDeviceid(devBase.getDevicecode());
        entity.setDevicename(devBase.getDevicename());
        entity.setDuration(Utils.makeRandInt(100));
        entity.setWeather(weather);
        entity.setWinddirection(windDirection);
        entity.setWindpower(windDirection);
        entity.setUuid(UUIDUtils.getUUID());
        return entity;
    }
}
